package com.woniu.woniuticket.dao;

import com.woniu.woniuticket.entity.Seat;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author spirit
 * @since 2020-01-02
 */
public interface SeatMapper extends BaseMapper<Seat> {

    @Select("select buy_table from seat_buy where show_session_id = #{showSessionId}")
    String getAllSeat(Integer showSessionId);

    @Select("select seat_num from seat where movie_hall_id = #{movieHallId}")
    String getInitialAllSeat(Integer movieHallId);

    @Insert("insert into seat_buy(show_session_id,buy_table) values(#{Id},#{seat}) ")
    int insertSeat(@Param("Id")Integer showSessionId,@Param("seat")String seat);

    @Update("update seat_buy set buy_table = #{seat} where show_session_id = #{showSessionId}")
    int updateSeatBuy(@Param("showSessionId")Integer showSessionId,@Param("seat")String seat);
}
